<template>
	<view class="OrderList">
		<view class="OrderList-title">订单信息</view>
		<view class="OrderList-item" v-for="(item,index) in OrderList" :key="index">
			<view class="item-img">
				<image :src="item.small_img" mode="widthFix"></image>
			</view>
			<view class="item-desc">
				<view class="desc-top">
					<view class="">{{item.name}}</view>
					<view class="desc-top-rule">{{item.rule}}</view>
				</view>
				<view class="desc-middle">
					{{item.enname}}
				</view>
				<view class="desc-bottom">
					<view class="desc-bottom-price">¥{{item.price}}</view>
					<view class="">x{{item.count}}</view>
				</view>
			</view>
		</view>
		<view class="OrderList-msg">
			<view class="msg-time">{{orderTime}}</view>
			<view class="msg-bottom">
				<view class="bottom-count">共计 {{sumCount}} 件</view>
				<view class="bottom-price">合计 ¥{{sumPrice}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		props:{
			OrderList:{
				type:Array
			},
			orderTime:{
				type:String
			}
		},
		computed:{
			sumPrice(){
				return	this.OrderList.reduce((prev,item)=>{
							return prev + item.count*item.price
						},0)                 		
			},
			sumCount(){
				return this.OrderList.reduce((prev,item)=>{
					return prev + item.count
				},0)
			}
		}
	}
</script>

<style scoped>
	.OrderList{
		margin-top: 40rpx;
	}
	.OrderList-item{
		display: flex;
		width: 100%;
		height: 168rpx;
		border: 1rpx solid #FFFFFF;
		margin-top: 30rpx;
	}
	.item-img{
		width: 25%;
	}
	.item-desc{
		margin-left: 10rpx;
		width: 65%;
	}
	.item-img>image{
		width: 100%;
	}
	.desc-top{
		display: flex;
	}
	.desc-top-rule{
		margin-left: 40rpx;
		color: #939393;
	}
	.desc-middle{
		color: #939393;
		margin-top: 15rpx;
		overflow: hidden;
		white-space: nowrap;
		text-overflow: ellipsis;
	}
	.desc-bottom{
		display: flex;
		justify-content: space-between;
		margin-top: 40rpx;
	}
	.desc-bottom-price{
		color: #0C34BA;
		font-weight: bold;
	}
	.OrderList-msg{
		margin-top: 40rpx;
		padding-top: 30rpx;
		border-top: 1rpx dashed #939393;
	}
	.msg-bottom{
		display: flex;
		justify-content: space-between;
		margin-top: 20rpx;
	}
	.bottom-price{
		font-weight: bold;
		color: #0C34BA;
	}
</style>
